package com.lagou.controller;

import com.lagou.dao.StudentDaoImpl;
import com.lagou.service.StudentService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;


@WebServlet(name = "DelServlet",urlPatterns = "/del")
public class DelServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        StudentService studentService = new StudentService(new StudentDaoImpl());
        String id = request.getParameter("id");
        int i = studentService.del(Integer.valueOf(id));
        if(i==1){
            System.out.println("删除成功");
        }else{
            System.out.println("删除失败");
        }
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request,response);
    }
}
